<?php
/*
 * Created on Feb 18, 2010
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
class CategoryModel{	
	
	function CategoryModel(){
		
	}
	
	function getCategories($offset = null, $limit = null) {
		global $connDB;   
		$sql = "SELECT * FROM ".TBL_CATEGORY." 
				WHERE deleteFlag = 0 
				ORDER BY sortNo DESC, updateDate DESC, name ASC " . getLimitFormat($offset, $limit);
		$result = $connDB->DB_query($sql,$connDB->connection);
		
      	return $result;
	}
	
	function getTypesByCategoryId($categoryId = null) {
		global $connDB;   
		$sql = "SELECT * FROM ".TBL_REALESTATE_TYPE." 
				WHERE deleteFlag = 0 AND rees_category_id = $categoryId
				ORDER BY sortNo DESC, updateDate DESC, name ASC ";
		$result = $connDB->DB_query($sql, $connDB->connection);
		
      	return $result;
	}
	
	function getTypeDetail($id = null) {
		global $connDB;   
		$sql = "SELECT cat.name cat_name, type.name type_name, type.createDate 
				FROM ".TBL_REALESTATE_TYPE." type 
				INNER JOIN ".TBL_CATEGORY." cat ON cat.id = type.rees_category_id
				WHERE type.deleteFlag = 0 AND type.id = $id 
				ORDER BY type.sortNo DESC, type.createDate DESC";  
		$result = $connDB->DB_query($sql, $connDB->connection);
		
      	return $connDB->DB_fetch_array($result);
	}
	
	function getArrayNameRegions($resultSet = null){
		global $connDB; 
		if($resultSet == null) return null;
		
		return $connDB->DB_fetch_array($resultSet);
	}
	
};

/* Create cityregion controller object */
$categoryModel = new CategoryModel;
?>
